import requestApi from "src/erm/sscrppublic/common/components/requestApi";
import _ from 'lodash-es';

import {ajax } from 'nc-lightapp-front';


let requestDomain =  '';

let requestApiOverwrite = {
    ...requestApi,
    
    query:(opt) => {
         ajax({
            url: `${requestDomain}/nccloud/erm/expenseaccount/ExpenseaccountInvoiceListQueryAction.do`,
            data: opt.data,
            success: (data) => {
                data = data.data;
                opt.success(data);
            }
        })
    },

    getWalletList:(opt) => {
        ajax({
           url: `${requestDomain}/nccloud/erm/expenseaccount/ExpenseaccountInvoiceNodeListQueryAction.do`,
           data: opt.data,
           success: (data) => {
               opt.success(data);
           },
           error: (data) => {
            opt.error(data);
        }
       })
   },

   getOrderList:(opt) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/ybzorder/NcTravelOrderListQueryAction.do`,
            data: opt.data,
            success: (data) => {
                opt.success(data);
            },
            error: (data) => {
                opt.error(data);
            }
        })
    },

    transfer2Table: (prams) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/expenseaccount/ExpenseaccountInvoiceToBxbodyAction.do`,
            data: prams.data,
            success: (data) => {
                data = data.data;
                prams.success(data);
            }
        })
    },

    delete: (prams) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/expenseaccount/ExpenseaccountInvoiceDeleteAction.do`,
            data: prams.data,
            success: (data) => {
                prams.success(data);
            }
        })
    },

    showInvoiceImg: (prams) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/erminvoice/ErmInvoiceSingleLinkAttachmentAction.do`,
            data: prams.data,
            success: (data) => {
                prams.success(data);
            },
            error: (err) => {
                console.log('error:', err)
            }
        })
    },
    // 移动至票袋
    bagMoveData: (prams) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/ybzinvoice/NcInvoiceMoveInBagAction.do`,
            data: prams.data,
            success: (data) => {
                if(data && data.success && Array.isArray(data.data)){
                    prams.success(data.data);
                }
            },
            error: (err) => {
                if(err && err.message){
                    toast({ color: 'warning', content: err.message}); /*扫描条码未查询到单据*/
                }
            }
        })
    },
    // // 移动至票袋
    // bagMoveData: (prams) => {
    //     ajax({
    //         url: `${requestDomain}/nccloud/erm/ybzinvoice/NcInvoiceMoveInBagAction.do`,
    //         data: prams.data,
    //         success: (data) => {
    //             if(data && data.success && Array.isArray(data.data)){
    //                 prams.success(data.data);
    //             }
    //         },
    //         error: (err) => {
    //             if(err && err.message){
    //                 toast({ color: 'warning', content: err.message}); /*扫描条码未查询到单据*/
    //             }
    //         }
    //     })
    // },
    // 移动至票袋按钮加载列表
    queryBagMoveData: (prams) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/ybzinvoice/NcInvoiceMoveBagListQueryAction.do`,
            data: prams.data,
            success: (data) => {
                if(data && data.success && Array.isArray(data.data)){
                    prams.success(data.data);
                }
            },
            error: (err) => {
                if(err && err.message){
                    toast({ color: 'warning', content: err.message}); /*扫描条码未查询到单据*/
                }
            }
        })
    },

    /**
     * @功能: 根据数据行的pk主键查看对应发票（base64）
     * @作者：Mr.sha
     * @日期：2022-06-08
     * @param {} prams 
     */
    invoiceQuery:(prams) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/expenseaccount/ExpenseaccountInvoiceQueryImageAction.do`,
            data: prams.data,
            success: (data) => {
                if(data && data.success && data.data){
                    prams.success(data.data);
                }
            },
            error: (err) => {
                if(err && err.message){
                    toast({ color: 'warning', content: err.message}); /*扫描条码未查询到单据*/
                }
            }
        })
    }



}

export default  requestApiOverwrite;